<?php

class CmsModule extends CWebModule
{
	public function init()
	{
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		$this->setImport(array(
			'Cms.models.*',
			'Cms.components.*',
		));
	}

	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}

    public function getMenus(){
        $isAdmin = Yii::app()->authManager->isAssigned('administrators', Yii::app()->user->id);
        return array(            
            array(
                'items'=>array(
                    array('label'=>'Sites|View and search sites','url'=>array('/Cms/admin/site/admin'),'visible'=>$isAdmin),
                    array('label'=>'Workflows|View and search workflows','url'=>array('/Cms/admin/workflow/admin'),'visible'=>$isAdmin),
                    array('label'=>'Widgets|View and search widget','url'=>array('/Cms/admin/widget/admin')),
                    array('label'=>'Templates|View and search templates','url'=>array('/Cms/admin/template/admin')),
                    array('label'=>'Pages|View and search pages','url'=>array('/Cms/admin/page/admin')),
                    array('label'=>'Site Content|Edit all content of all pages','url'=>array('/Cms/admin/page/masterContent')),
                )
            ),
        );
    }
}
